package xinxin.com.FlyweightPattern.Factory;

import xinxin.com.FlyweightPattern.WebSite.ConcreteWebSite;
import xinxin.com.FlyweightPattern.WebSite.WebSite;

import java.util.Hashtable;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/2 22:20
 */
public class WebSiteFactory {
    private Hashtable flyweights = new Hashtable();
    // 获得网站分类
    public WebSite GetWebSiteCategory(String key) {
        if (!flyweights.containsKey(key)) {
            flyweights.put(key, new ConcreteWebSite(key));
        }
        return (WebSite)flyweights.get(key);
    }

    // 获得网站分类总数
    public int GetWebSiteCount() {
        return flyweights.size();
    }
}
